var myLayout;
$(function () {
    myLayout = $('body').layout({
        north__minSize: 50, north__maxSize: 400, togglerContent_open: '<div class="ui-icon"></div>', togglerContent_closed: '<div class="ui-icon"></div>'
        // , spacing_open: 10
        // , spacing_closed: 10
    });
    $("#jqGrid").jqGrid({
        url: ctx + "/mge/adx/listUser?rad=" + new Date().getTime(),
        datatype: "json",
        colModel: [
            {label: '用户ID', name: 'userId', index: "user_id", width: 45, align: 'center', key: true},
            {label: '用户名', name: 'username', width: 75},
            {label: '邮箱', name: 'email', width: 90},
            {label: '手机号', name: 'mobile', width: 100},
            {
                label: '状态', name: 'status', width: 60, formatter: function (value, options, row) {
                return value === 0 ?
                    '<span class="label label-danger">禁用</span>' :
                    '<span class="label label-success">正常</span>';
            }
            },
            {label: '创建时间', name: 'createTime', index: "create_time", width: 85}
        ],
        viewrecords: true,//显示数据总记录数
        height: 385,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        recordpos: 'right',
        altRows: true,//隔行变色
        altClass: '',
        rownumWidth: 25,
        autowidth: true,//自动宽高
        multiselect: true,//复选框
        pager: "#jqGridPager",
        jsonReader: {
            id: "userId",
            root: "rows",
            page: "page",
            total: "pages",
            records: "total"
        },
        prmNames: {
            page: "pageNumber",
            rows: "pageSize",
            order: "order"
        },
        loadComplete: function (data) {
            //当服务器返回响应时执行
        },
        loadError: function (xhr, stat, erro) {

        },
        gridComplete: function () {
            //
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
});

function reload() {
    var page = $("#jqGrid").jqGrid('getGridParam', 'page');
    $("#jqGrid").jqGrid('setGridParam', {
        postData: {'username': vm.q.username},
        page: page
    }).trigger("reloadGrid");
}

